//
//  TDSwipeCardViewController.m
//  TFB
//
//  Created by Nothing on 15/3/18.
//  Copyright (c) 2015年 TD. All rights reserved.
//

#import "TDSwipeCardViewController.h"
#import "CJCommon.h"

@interface TDSwipeCardViewController ()
{
    NSString *_termNo;
    NSString *_track;
    NSString *_pinblk;
    NSString *_random;
    NSString *_period;
    NSString *_icdata;
    NSString *_crdnum;
}
@end

@implementation TDSwipeCardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"刷卡";
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    self.payMoneyLabel.text = self.payMoney;

    
    [self shuaka];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)shuaka
{
    
}

- (void)checkCardWithData{
    NSMutableDictionary *optionDict = [NSMutableDictionary dictionary];
    [optionDict setObject:[NSNumber numberWithInt:30] forKey:@"checkCardTimeout"];
   
    
    //[[EmvSwipeController sharedController] getEmvCardNumber];
}




- (void)btnAction_StartEmvWithData:(id)sender{
    NSLog(@"btnAction_StartEmvWithData");
    NSString *terminalTime = @""; //e.g. 130108152010 (YYMMddHHmmss)
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"YYMMddHHmmss"];
    [formatter setTimeZone:[NSTimeZone localTimeZone]];
    terminalTime = [formatter stringFromDate:[NSDate date]];
    
    
    NSMutableDictionary *optionDict = [NSMutableDictionary dictionary];
    [optionDict setObject:terminalTime forKey:@"terminalTime"];
    //Timeouts are configurable [Require FW 7.11c or above]
    [optionDict setObject:[NSNumber numberWithInt:30] forKey:@"checkCardTimeout"];
    [optionDict setObject:[NSNumber numberWithInt:30] forKey:@"setAmountTimeout"];
    [optionDict setObject:[NSNumber numberWithInt:30] forKey:@"selectApplicationTimeout"];
    [optionDict setObject:[NSNumber numberWithInt:30] forKey:@"onlineProcessTimeout"];
    [optionDict setObject:[NSNumber numberWithInt:30] forKey:@"finalConfirmTimeout"];
}

- (void)onRequestSetAmount
{
    
}

- (void)onRequestFinalConfirm{
    
    NSLog(@"onRequestFinalConfirm");
    
  
}

- (void)onRequestPinEntry
{
  
}

- (void)onRequestOnlineProcess:(NSString *)tlv{
    NSLog(@"tlvStr  %@", tlv);
  
    
//    NSString *_termNo;
//    NSString *_track;
//    NSString *_pinblk;
//    NSString *_random;
//    NSString *_period;
//    NSString *_icdata;
//    NSString *_crdnum;
    
   
    _pinblk = [CJCommon pinResultMak:@"" account:@"" passwd:@"123456"];
    
    //[CJCommon pinResultMak:@"" account:@"" passwd:@""];
    
    
}


- (IBAction)payBtnClick:(id)sender {
    
    [TDHttpEngine requestForPayWithCustId:@"15040300000025" custMobile:@"13273901442" prdordNo:@"20150403000000004" payType:@"02" rate:@"2" termNo:@"CF0300000206" termType:@"02" payAmt:self.payMoney track:@"0|24|0|8D6380A8E375BBFDEE49F51BFA38E24D" pinblk:@"F431288949F99892" random:@"366DECCB04A885C8" mediaType:@"02" period:@"2002" icdata:@"63FE5C8A8D92DA0BC9EB7233D6FFB22436C1117F1AB3E949586FBBDE43D01784EFC73684608482B45E353CE0B8112F46AF568B76D6E66E996A4F2C4E820F6023B32DFD717B2BF133D7604D26BB07EF5CF4C737DF110010F1BF44E61AF5455D5CBFF456904A379ADEC026836D9C99B24DFDF90754126F29182EFCA35F8376D3F3132CD80AB723474E147D77B15F2D8B75240769361DF509D1" crdnum:@"001" mac:@"" complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (succeed) {
            
        }
        else{
            
        }
        NSLog(@"%@ , %@", msg, cod);
    }];
}
@end
